package com.second.order.controller;

import com.second.common.pojo.R;
import com.second.order.pojo.vo.OrderRecordQueryVo;
import com.second.order.pojo.vo.OrderRecordVo;
import com.second.order.pojo.vo.PageVo;
import com.second.order.pojo.vo.RecordAndCostVo;
import com.second.order.service.OrderRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (OrderRecord)表控制层
 *
 * @author makejava
 * @since 2021-07-30 19:49:02
 */
@RestController
@RequestMapping("order")
@Api(tags = "订单记录表控制层")
public class OrderRecordController{

    /**
     * 服务对象
     */
    @Resource
    private OrderRecordService orderRecordService;

    /**
     * 查询所有的客户信息
     * @param pageVo 分页工具类
     * @param recordQueryVo 模糊查询工具类
     * @return 所有数据
     */
    @PostMapping("getAllOrderRecord")
    @ApiOperation(value = "查询所有的客户信息")
    public R getAllOrderRecord(PageVo pageVo,@RequestBody OrderRecordQueryVo recordQueryVo) {
        return orderRecordService.getAllOrderRecord(pageVo,recordQueryVo);
    }

    /**
     * 获取订单的费用明细
     * @param costId 费用id
     * @return 费用明细数据
     */
    @GetMapping("getAllCostInfo")
    @ApiOperation(value = "获取订单的费用明细")
    @ApiImplicitParam(name = "costId",value = "费用id")
    public R getAllCostInfo(Integer costId) {
        return orderRecordService.getAllCostInfo(costId);
    }

    /**
     * 修改订单中的实际取车时间
     * @param orderNumber 订单编号
     * @return 修改结果
     */
    @GetMapping("updateActualPickTime")
    @ApiOperation(value = "修改订单中的实际取车时间")
    @ApiImplicitParam(name = "orderNumber",value = "订单编号")
    public R updateActualPickTime(String orderNumber) {
        return orderRecordService.updateActualPickTime(orderNumber);
    }

    /**
     * 修改订单中的实际还车时间
     * @param orderNumber 订单编号
     * @return 修改结果
     */
    @GetMapping("updateActualReturnTime")
    @ApiOperation(value = "修改订单中的实际还车时间")
    @ApiImplicitParam(name = "orderNumber",value = "订单编号")
    public R updateActualReturnTime(String orderNumber) {
        return orderRecordService.updateActualReturnTime(orderNumber);
    }

    /**
     * 根据订单id，查询出订单的详细信息
     * @param orderId 订单id
     * @return 数据结果
     */
    @GetMapping("getOrderInfoByOrderId")
    @ApiOperation(value = "根据订单id，查询出订单的详细信息")
    @ApiImplicitParam(name = "orderId",value = "订单id")
    public R getOrderInfoByOrderId(Integer orderId) {
        return orderRecordService.getOrderInfoByOrderId(orderId);
    }

    /**
     * 下订单，添加订单详情
     * @param orderRecordVo 订单详情
     * @return 下单结果
     */
    @PostMapping("placeOrder")
    @ApiOperation(value = "下订单，添加订单详情")
    public R placeOrder(@RequestBody OrderRecordVo orderRecordVo) {
        return orderRecordService.placeOrder(orderRecordVo);
    }

    /**
     * 支付订单
     * @param recordAndCostVo 订单详情和费用明细
     * @return 支付结果
     */
    @PostMapping("paymentOrder")
    @ApiOperation(value = "支付订单")
    public R paymentOrder(@RequestBody RecordAndCostVo recordAndCostVo) {
        return orderRecordService.paymentOrder(recordAndCostVo);
    }

    /**
     * 根据会员id，查询所有的订单
     * @param clientId 会员id
     * @return 数据结果
     */
    @GetMapping("getOrderByClientId")
    @ApiOperation(value = "根据会员id，查询所有的订单")
    @ApiImplicitParam(name = "clientId",value = "会员id")
    public R getOrderByClientId(Integer clientId) {
        return orderRecordService.getOrderByClientId(clientId);
    }

}
